//
//  PasswordManageViewController.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/12.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "PasswordManageViewController.h"
#import "ModifyLoginPasswordViewController.h"
#import "SetPayPasswordViewController.h"
#import "ModifyPayPasswordViewController.h"


@interface PasswordManageViewController ()

@property (strong, nonatomic) UIView *payPasswordView;
@property (strong, nonatomic) UILabel *payPasswordL;
@property (strong, nonatomic) UIImageView *arrowIV;

@property (strong, nonatomic) UIView *loginView;
@property (strong, nonatomic) UILabel *loginL;
@property (strong, nonatomic) UIImageView *arrowIV1;

@end

@implementation PasswordManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = WhiteColor;
    
    self.title = @"密码管理";
    
    [self createUI];
    
}

#pragma mark -支付密码
- (void)paypasswordGestureClick:(UIGestureRecognizer *)recognizer {
    
    NSLog(@"支付密码");
    
    if ([CommonUserInfo sharedInstance].is_setPayPassword) {
        // 修改支付密码
        ModifyPayPasswordViewController *vc = [[ModifyPayPasswordViewController alloc] init];
        
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        // 设置支付密码
        
        SetPayPasswordViewController *vc = [[SetPayPasswordViewController alloc] init];
        vc.controllerType = SetPayPasswordType;
        [self.navigationController pushViewController:vc animated:YES];
    }

    
}

#pragma mark -修改登录密码
- (void)loginGestureClick:(UIGestureRecognizer *)recognizer {
    
    NSLog(@"修改登录密码");

    ModifyLoginPasswordViewController *vc = [[ModifyLoginPasswordViewController alloc] initWithControllerType:UIViewControllerModifyPasswordType withPhoneNum:[CommonUserInfo sharedInstance].phone];
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (void)createUI {
    
    [self.view addSubview:self.payPasswordView];
    [self.payPasswordView addSubview:self.payPasswordL];
    [self.payPasswordView addSubview:self.arrowIV];
    
    [self.view addSubview:self.loginView];
    [self.loginView addSubview:self.loginL];
    [self.loginView addSubview:self.arrowIV1];
    
    
    __weak typeof(self) weakSelf = self;
    [self.payPasswordView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left);
        make.right.mas_equalTo(weakSelf.view.mas_right);
        make.top.mas_equalTo(weakSelf.view.mas_top);
        make.height.mas_equalTo(jisuan(74));

    }];
    [self.payPasswordL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.payPasswordView.mas_left).with.offset(jisuan(40));
        make.centerY.mas_equalTo(weakSelf.payPasswordView.mas_centerY);
        
    }];
    [self.arrowIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.payPasswordView.mas_right).with.offset(-jisuan(30));
        make.centerY.mas_equalTo(weakSelf.payPasswordView.mas_centerY);
        make.width.mas_equalTo(jisuan(12));
        make.height.mas_equalTo(jisuan(20));
        
    }];
    
    [self.loginView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left);
        make.right.mas_equalTo(weakSelf.view.mas_right);
        make.top.mas_equalTo(weakSelf.payPasswordView.mas_bottom);
        make.height.mas_equalTo(jisuan(74));
        
    }];
    [self.loginL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.loginView.mas_left).with.offset(jisuan(40));
        make.centerY.mas_equalTo(weakSelf.loginView.mas_centerY);
        
    }];
    [self.arrowIV1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.loginView.mas_right).with.offset(-jisuan(30));
        make.centerY.mas_equalTo(weakSelf.loginView.mas_centerY);
        make.width.mas_equalTo(jisuan(12));
        make.height.mas_equalTo(jisuan(20));
        
    }];
}

#pragma mark -lazy
- (UIView *)payPasswordView {
    
    if (!_payPasswordView) {
        
        _payPasswordView = [[UIView alloc] init];
        
        UITapGestureRecognizer *payPasswordGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(paypasswordGestureClick:)];
        [_payPasswordView addGestureRecognizer:payPasswordGesture];
    
    }
    
    return _payPasswordView;
}
- (UILabel *)payPasswordL {
    
    if (!_payPasswordL) {
        
        _payPasswordL = [[UILabel alloc] init];
//        _payPasswordL.text = [[CommonUserInfo sharedInstance].userInfoModel.is_paypass boolValue] ? @"修改支付密码" : @"设置支付密码";
        
        _payPasswordL.text = [CommonUserInfo sharedInstance].is_setPayPassword ? @"修改登录密码" : @"设置支付密码";
        _payPasswordL.textColor = Color333333;
        _payPasswordL.textAlignment = NSTextAlignmentLeft;
        _payPasswordL.font = Font(24);
        
    }
    return _payPasswordL;
}

- (UIImageView *)arrowIV {
    
    if (!_arrowIV) {
        
        _arrowIV = [[UIImageView alloc] init];
        _arrowIV.contentMode = UIViewContentModeScaleAspectFit;
        _arrowIV.image = [UIImage imageNamed:@"rightArrowBG"];
    }
    
    return _arrowIV;
}


- (UIView *)loginView {
    
    if (!_loginView) {
        
        _loginView = [[UIView alloc] init];
        
        UITapGestureRecognizer *loginGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loginGestureClick:)];
        [_loginView addGestureRecognizer:loginGesture];
        
    }
    
    return _loginView;
}
- (UILabel *)loginL {
    
    if (!_loginL) {
        
        _loginL = [[UILabel alloc] init];
        _loginL.text = @"修改登录密码";
        _loginL.textColor = Color333333;
        _loginL.textAlignment = NSTextAlignmentLeft;
        _loginL.font = Font(24);
        
    }
    return _loginL;
}

- (UIImageView *)arrowIV1 {
    
    if (!_arrowIV1) {
        
        _arrowIV1 = [[UIImageView alloc] init];
        _arrowIV1.contentMode = UIViewContentModeScaleAspectFit;
        _arrowIV1.image = [UIImage imageNamed:@"rightArrowBG"];
    }
    
    return _arrowIV1;
}
#pragma mark -设置
- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
//    self.tabBarController.tabBar.hidden = YES;
    
    self.payPasswordL.text = [CommonUserInfo sharedInstance].is_setPayPassword ? @"修改支付密码" : @"设置支付密码";

}
- (void)viewWillDisappear:(BOOL)animated {
    
    [super viewWillDisappear:animated];
    
//    self.navigationController.navigationBar.hidden = NO;
//    self.tabBarController.tabBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
